public class Test {
    public static ListNode addTwoNumbers(ListNode l1, ListNode l2) {
        int n1 = 0,n2 = 0;
        while(l1 != null){
            int i = 1;
            n1 += l1.val*Math.pow(10,i-1);
            i++;
            l1 = l1.next;
        }
        while(l2 != null){
            int i = 1;
            n2 += l2.val*Math.pow(10,i-1);
            i++;
            l2 = l2.next;
        }
        int n = n1 + n2;
        ListNode ans = new ListNode(n % 10);
        while(n != 0){
            //尾插
            n = n / 10;
            ListNode node = new ListNode(n % 10);
            ans.next = node;
        }
        return ans;
    }

    public static void main(String[] args) {
        ListNode l1 = new ListNode(2);

        ListNode l2 = new ListNode(5);
        ListNode ans = addTwoNumbers(l1,l2);
    }
}
